{% extends 'ViettransFrontBundle::layout.html.twig' %}

{% block search %}
    {% render 'ViettransFrontBundle:Partial:search' with {'request':app.request} %}
{% endblock %}

{% block pagination %}
    {% render 'ViettransFrontBundle:Partial:pagination' with {'request':app.request} %}
{% endblock %}

{% block body %}
<div id="announcement_index" class="grid_24">
    <table id="announcements">
        {% for announcement in announcements %}
            <tr>
                <td class="announcement">
                    <div class="date_time grid_2 alpha">
                        <div class="date">
                            {% if announcement.beginsAt|date("m/d/Y") == "now"|date("m/d/Y") %} 
                                Hôm nay
                            {% else %}
                                {{ announcement.beginsAt|date('d / m') }}
                            {% endif %}
                        </div>
                        <div class="time">{{ announcement.beginsAt|date('H:i') }}</div>
                    </div>
                    <div class="grid_3">
                        <div class="photo">
                            <a title="{{ announcement.title }}" href="{{ path('announcement_show', {'id': announcement.id}) }}"><img alt="photo" src="{{ asset(announcement.photos != '' ?'images/announcement/thumb/' ~ announcement.photos ~ '.jpg' : 'images/announcement/thumb/noThumb80x60.jpg') }}" /></a>
                        </div>
                    </div>
                    <div class="grid_12">
                        <div class="title"><a title="{{ announcement.title }}" href="{{ path('announcement_show', {'id': announcement.id}) }}">{{ announcement.title }}</a></div>
                        <div class="price">{{ announcement.price != '' ? announcement.price ~ ' €' : '-' }}</div>
                        <div class="category_locality"><i>{{ announcement.categoryObj.name }} / {{ announcement.townObj.name }} ({{ announcement.townObj.code }})</i></div>
                    </div>
                    <div class="grid_5">
                        {% if announcement.userId %}
                            <div>Nguoi dung {{ announcement.userObj.name }}</div>
                        {% endif %}
                    </div>
                </td>
            </tr>
        {% else %}
            <tr>
                <td class="announcement">
                    <div class="error">{{ 'announcement.index.empty.text' | trans }}</div>
                </td>
            </tr>
        {% endfor %}
    </table>
</div>

{% render 'ViettransFrontBundle:Partial:pagination' with {'request':app.request} %}

{% endblock %}